home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / a3drot1a / 3dspin.frm next >
Text File  |  1999-10-18  |  23KB  |  595 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   5910
  6.    ClientLeft      =   2625
  7.    ClientTop       =   5070
  8.    ClientWidth     =   10380
  9.    FillStyle       =   0  'Solid
  10.    ForeColor       =   &H00000000&
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5910
  13.    ScaleWidth      =   10380
  14.    Begin VB.PictureBox Pic3D 
  15.       AutoRedraw      =   -1  'True
  16.       FillStyle       =   0  'Solid
  17.       ForeColor       =   &H00000000&
  18.       Height          =   2400
  19.       Left            =   2760
  20.       ScaleHeight     =   2340
  21.       ScaleWidth      =   2340
  22.       TabIndex        =   17
  23.       Top             =   360
  24.       Width           =   2400
  25.    End
  26.    Begin VB.PictureBox PicSTB 
  27.       AutoRedraw      =   -1  'True
  28.       FillStyle       =   0  'Solid
  29.       Height          =   2400
  30.       Left            =   7800
  31.       ScaleHeight     =   2340
  32.       ScaleWidth      =   2340
  33.       TabIndex        =   15
  34.       Top             =   3120
  35.       Width           =   2400
  36.    End
  37.    Begin VB.PictureBox PicFTB 
  38.       AutoRedraw      =   -1  'True
  39.       FillStyle       =   0  'Solid
  40.       Height          =   2400
  41.       Left            =   7800
  42.       ScaleHeight     =   2340
  43.       ScaleWidth      =   2340
  44.       TabIndex        =   13
  45.       Top             =   360
  46.       Width           =   2400
  47.    End
  48.    Begin VB.CommandButton BUTNStop 
  49.       Caption         =   "Stop"
  50.       Height          =   255
  51.       Left            =   240
  52.       TabIndex        =   9
  53.       Top             =   1560
  54.       Width           =   1935
  55.    End
  56.    Begin VB.CommandButton BUTNStart 
  57.       Caption         =   "Start"
  58.       Height          =   255
  59.       Left            =   240
  60.       TabIndex        =   8
  61.       Top             =   1200
  62.       Width           =   1935
  63.    End
  64.    Begin VB.CommandButton BUTNReset 
  65.       Caption         =   "Reset"
  66.       Height          =   255
  67.       Left            =   240
  68.       TabIndex        =   7
  69.       Top             =   1920
  70.       Width           =   1935
  71.    End
  72.    Begin VB.PictureBox PicTop 
  73.       AutoRedraw      =   -1  'True
  74.       FillStyle       =   0  'Solid
  75.       Height          =   2400
  76.       Left            =   5280
  77.       ScaleHeight     =   2340
  78.       ScaleWidth      =   2340
  79.       TabIndex        =   6
  80.       Top             =   3120
  81.       Width           =   2400
  82.    End
  83.    Begin VB.Timer Timer1 
  84.       Enabled         =   0   'False
  85.       Interval        =   50
  86.       Left            =   4560
  87.       Top             =   2760
  88.    End
  89.    Begin VB.CommandButton BUTNQuit 
  90.       Caption         =   "Quit"
  91.       Height          =   255
  92.       Left            =   240
  93.       TabIndex        =   4
  94.       Top             =   2280
  95.       Width           =   1935
  96.    End
  97.    Begin VB.CommandButton BUTNOKAY 
  98.       Caption         =   "Move"
  99.       Height          =   255
  100.       Left            =   240
  101.       TabIndex        =   3
  102.       Top             =   840
  103.       Width           =   1935
  104.    End
  105.    Begin VB.TextBox TEXTAngle 
  106.       Height          =   285
  107.       Left            =   1320
  108.       TabIndex        =   2
  109.       Top             =   360
  110.       Width           =   855
  111.    End
  112.    Begin VB.PictureBox PicFRL 
  113.       AutoRedraw      =   -1  'True
  114.       FillStyle       =   0  'Solid
  115.       Height          =   2400
  116.       Left            =   5280
  117.       ScaleHeight     =   2340
  118.       ScaleWidth      =   2340
  119.       TabIndex        =   1
  120.       Top             =   360
  121.       Width           =   2400
  122.    End
  123.    Begin VB.PictureBox PicXY 
  124.       AutoRedraw      =   -1  'True
  125.       FillStyle       =   0  'Solid
  126.       Height          =   2400
  127.       Left            =   2760
  128.       ScaleHeight     =   2340
  129.       ScaleWidth      =   2340
  130.       TabIndex        =   0
  131.       Top             =   3120
  132.       Width           =   2400
  133.    End
  134.    Begin VB.Label Label17 
  135.       Caption         =   "3D rotation"
  136.       Height          =   255
  137.       Left            =   2760
  138.       TabIndex        =   18
  139.       Top             =   120
  140.       Width           =   2295
  141.    End
  142.    Begin VB.Label Label16 
  143.       Caption         =   "Side, Top to Bottom Rotation"
  144.       Height          =   255
  145.       Left            =   7800
  146.       TabIndex        =   16
  147.       Top             =   2880
  148.       Width           =   2295
  149.    End
  150.    Begin VB.Label Label15 
  151.       Caption         =   "Front, Top to Bottom Rotation"
  152.       Height          =   255
  153.       Left            =   7800
  154.       TabIndex        =   14
  155.       Top             =   120
  156.       Width           =   2295
  157.    End
  158.    Begin VB.Label Label14 
  159.       Caption         =   "Top, Right to Left Rotation"
  160.       Height          =   255
  161.       Left            =   5280
  162.       TabIndex        =   12
  163.       Top             =   2880
  164.       Width           =   2295
  165.    End
  166.    Begin VB.Label Label13 
  167.       Caption         =   "Front, Right to Left Rotation"
  168.       Height          =   255
  169.       Left            =   5280
  170.       TabIndex        =   11
  171.       Top             =   120
  172.       Width           =   2295
  173.    End
  174.    Begin VB.Label Label11 
  175.       Caption         =   "Front, Stationary"
  176.       Height          =   255
  177.       Left            =   2760
  178.       TabIndex        =   10
  179.       Top             =   2880
  180.       Width           =   1575
  181.    End
  182.    Begin VB.Label Label12 
  183.       Caption         =   "Current Angle:"
  184.       Height          =   255
  185.       Left            =   240
  186.       TabIndex        =   5
  187.       Top             =   360
  188.       Width           =   1095
  189.    End
  190. End
  191. Attribute VB_Name = "Form1"
  192. Attribute VB_GlobalNameSpace = False
  193. Attribute VB_Creatable = False
  194. Attribute VB_PredeclaredId = True
  195. Attribute VB_Exposed = False
  196. Dim Angle As Double             'The rotation angle
  197. Dim AngleHolder As Double       'holder for previous rotation angle
  198. Dim NumObjectSides As Integer   'Number of sides making up the object
  199.  
  200. Private Type Point              'The makeup of a point
  201.     X As Double                 'the X location of the point
  202.     Y As Double                 'the Y location of the point
  203.     Z As Double                 'the Z location of the point
  204. End Type
  205. Dim Center As Point             'center of the picboxes
  206.  
  207. Private Type Verticies          'The verticies of a side
  208.     NumPoints As Integer        'The number of points on a line
  209.     Points(20) As Point         'the actual endpoints of each line
  210.     Normal As Point             'The normal of the Plane
  211. End Type
  212. Dim Sides(50) As Verticies      'the sides of the object
  213. Dim XSides(50) As Verticies     'the X rotation points
  214. Dim YSides(50) As Verticies     'the Y rotation points
  215. Dim ZSides(50) As Verticies     'the Z rotation points
  216. Dim Sides3D(50) As Verticies    'the 3D rotation of points
  217.  
  218. Dim CosAng(359) As Double       'A lookup table to hold the Cosine Angles
  219. Dim SinAng(359) As Double       'A lookup table to hold the Sine Angles
  220.  
  221.  
  222. Private Type POINTAPI           'This is the drawn Points of the
  223.   X As Long                     'object to fill it and draw it fast
  224.   Y As Long                     'using a win api function
  225. End Type
  226.  
  227. Dim tmp() As POINTAPI
  228. 'This function is for drawing filled polygons Much faster than anything I wrote
  229. Private Declare Function Polygon Lib "gdi32" _
  230.   (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
  231.  
  232.  
  233. Private Sub BUTNOKAY_Click()
  234.     'set the angle and draw the rotation
  235.     AngleHolder = AngleHolder + 5       'increment the angle
  236.     
  237.     If AngleHolder = 360 Then           'reset the angle back to 0
  238.         AngleHolder = 0
  239.     End If
  240.         
  241.     TEXTAngle.Text = AngleHolder        'display the current angle
  242.     Angle = AngleHolder                 'Set the angle for calculations
  243.     
  244.     Redraw                              'refresh the display
  245.    
  246. End Sub
  247.  
  248. Private Sub BUTNQuit_Click()
  249.     End                                 'end the program
  250. End Sub
  251.  
  252. Private Sub BUTNReset_Click()
  253.     AngleHolder = 355                   'reset so displayed angle will be 0
  254.     BUTNOKAY_Click